package iqq.ui.view.panel.login;

import iqq.common.IQQConstants;
import iqq.util.LanguageLoader;
import iqq.util.NinePatchUtils;

import java.awt.Color;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import com.alee.extended.panel.CenterPanel;
import com.alee.extended.panel.GroupPanel;
import com.alee.laf.label.WebLabel;
import com.alee.laf.panel.WebPanel;

/**
 * @author ChenZhiHui
 * @create-time 2013-3-8
 */
public class FooterPl extends WebPanel {
	private static final long serialVersionUID = 8937757628773498343L;

	private Color color = Color.GRAY;
	private Color enteredColor = Color.RED;

	private WebLabel regAccountLbl;
	private WebLabel forgetPwdLbl;
	private WebLabel settingLbl;
	private GroupPanel groupPanel;

	private LabelMouseListener lblMouseListener;

	public FooterPl() {
		initComponent();
		initMonitor();
		addComponent();
	}

	private void initMonitor() {
		lblMouseListener = new LabelMouseListener();
		regAccountLbl.addMouseListener(lblMouseListener);
		forgetPwdLbl.addMouseListener(lblMouseListener);
		settingLbl.addMouseListener(lblMouseListener);
	}

	private void addComponent() {
		CenterPanel cp = new CenterPanel(groupPanel);
		cp.setMargin(0, 0, 80, 0);
		add(cp);
	}

	private void initComponent() {
		Insets insets = new Insets(0, 10, 0, 10);
		regAccountLbl = new WebLabel(LanguageLoader.getString("regAccount"));
		forgetPwdLbl = new WebLabel(LanguageLoader.getString("forgetPwd"));
		settingLbl = new WebLabel(LanguageLoader.getString("setting"));

		regAccountLbl.setForeground(color);
		forgetPwdLbl.setForeground(color);
		settingLbl.setForeground(color);

		regAccountLbl.setMargin(insets);
		forgetPwdLbl.setMargin(insets);
		settingLbl.setMargin(insets);

		groupPanel = new GroupPanel(true, regAccountLbl, forgetPwdLbl,
				settingLbl);
		groupPanel.setMargin(0, 0, 3, 0);
		groupPanel.setPainter(NinePatchUtils
				.getNinePatchIconPainter(IQQConstants.NP_SHADOW_LINE));
	}

	class LabelMouseListener implements MouseListener {

		@Override
		public void mouseClicked(MouseEvent e) {

		}

		@Override
		public void mousePressed(MouseEvent e) {

		}

		@Override
		public void mouseReleased(MouseEvent e) {

		}

		@Override
		public void mouseEntered(MouseEvent e) {
			if (e.getComponent() == regAccountLbl) {
				regAccountLbl.setForeground(enteredColor);
			} else if (e.getComponent() == forgetPwdLbl) {
				forgetPwdLbl.setForeground(enteredColor);
			} else if (e.getComponent() == settingLbl) {
				settingLbl.setForeground(enteredColor);
			}
		}

		@Override
		public void mouseExited(MouseEvent e) {
			if (e.getComponent() == regAccountLbl) {
				regAccountLbl.setForeground(color);
			} else if (e.getComponent() == forgetPwdLbl) {
				forgetPwdLbl.setForeground(color);
			} else if (e.getComponent() == settingLbl) {
				settingLbl.setForeground(color);
			}
		}

	}
}
